<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      div {
        width: 200px;
        height: 200px;
        border: 1px solid #000;
      }
    </style>
  </head>
  <body>
    <div></div>
    <button>事件解绑</button>
    <script>
      var div = document.querySelector("div");
      var button = document.querySelector("button");

      div.onmouseover = function () {
        alert("ok");
      };
      // 点击button按钮时将 div标签对象身上的事件进行解绑
      button.onclick = function () {
        div.onmouseover = null;
      };
    </script>
  </body>
</html>
